﻿document.addEventListener("DOMContentLoaded", function () {
    var btncode = document.querySelector(".style_btnH");
    console.log(btncode);
    btncode.addEventListener("click", function () {
        btncode.disabled = true;
        var num = 60;
        var time = setInterval(function () {
          /*  if (num === 0) {
                clearInterval(time);
                num = 30;
                btncode.disabled = false;
                btncode.value = "获取验证码";
                btncode.style.color = "#000";
                btncode.className = "btncode";
                return;
            }*/
            btncode.value = "剩" + num + "s";
            num--;
            if (num === 57) {
                clearInterval(time);               
                btncode.disabled = false;
                var arr = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j"];
                var str = "";
                for (var i = 0; i < 4; i++) {
                    str += arr[Math.round(Math.random() * (20 - 0) + 0)];
                }
                btncode.value = str;
                return;
            }
        }, 1000);
    });
});